const { createProxyMiddleware } = require('http-proxy-middleware');


//  /students  5000   /cars  5001
module.exports = function (app) {
    app.use(
        '/api1',
        createProxyMiddleware({
            target: 'http://localhost:5000',
            changeOrigin: true,   //固定写法, 用来伪装 host 请求头, 提高跨域请求成功率
            pathRewrite: {'^/api1': ''} //调整路径
        }),
    );

    app.use(
        '/api2',
        createProxyMiddleware({
            target: 'http://localhost:5001',
            changeOrigin: true,   //固定写法, 用来伪装 host 请求头, 提高跨域请求成功率
            pathRewrite: {'^/api2': ''} //调整路径
        })
    );

    app.use(
        '/meituan',
        createProxyMiddleware({
            target: 'https://bj.meituan.com',
            changeOrigin: true,   //固定写法, 用来伪装 host 请求头, 提高跨域请求成功率
            pathRewrite: {'^/meituan': ''} //调整路径
        })
    );
    
};